$(function() {
	$('#vue_vm_list div').hide();
});

function foodMealsApply_findPersonDetail() {
	if($('#vue_vm_list div').length==0) {return;}
	$('#vue_vm_list div').hide();
	var searchVal = $('#searchVal').val();
	if(!searchVal || searchVal=='') {
		alert('请输入长者姓名或身份证');
		return;
	}

	find_basic_by_json(path+'/foodMealsApply/findPersonDetail', {searchVal:searchVal}, function(response) {
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: response.data
			},
			methods: {
				getSubsidizationValue:function(subsidization, subsidizationValue) {
					return getSubsidizationValue(subsidization, subsidizationValue);
				},
				getSubsidizationUnit:function(subsidization) {
					return getSubsidizationUnit(subsidization);
				},
				getSubsidizationText:function(subsidization, subsidizationValue) {
					return getSubsidizationText(subsidization, subsidizationValue);
				},
				getConsDeductionText:function(consumptionWay, consDeductionWay) {
					return getConsDeductionText(consumptionWay, consDeductionWay);
				},
				//总共可扣月数
				getTotalMonths:function(todo) {
					return getTotalMonths(todo);
				},
				//剩余可扣月数
				getRemainMonths:function(todo) {
					return getRemainMonths(todo);
				},
				//已扣月数
				getAlreadyUsedMonths:function(todo) {
					return getAlreadyUsedMonths(todo);
				},
				//总共可扣天数
				getTotalNumber:function(todo) {
					return getTotalNumber(todo);
				},
				//剩余可扣天数
				getRemainNumber:function(todo) {
					return getRemainNumber(todo);
				},
				//已扣天数
				getAlreadyUsedNumber:function(todo) {
					return getAlreadyUsedNumber(todo);
				}
			}
		});
		
		$('#vue_vm_list div').show();
	});
}

function foodMealsApply_save() {
	var relationId = $('input:radio[name="relationPerson"]:checked').attr('id');
	var foodMealsApply = {};
	foodMealsApply.relationId = relationId;
	foodMealsApply.relationName = $('input:radio[name="relationPerson"]:checked').attr('relationName');
	foodMealsApply.relationCardId = $('input:radio[name="relationPerson"]:checked').attr('relationCardId');
	foodMealsApply.relationType = $('input:radio[name="relationPerson"]:checked').attr('relationType');
	foodMealsApply.foodMealsId = $('#foodMeals_select').val();
	foodMealsApply.approveStatus = 0;
	
	if(isEmpty(relationId)) {
		alert('请选择人员');
		return;
	}
	
	if(isEmpty(foodMealsApply.foodMealsId)) {
		alert('请选择包餐');
		return;
	}
	
	save_basic(path+'/foodMealsApply/save', {foodMealsApply:foodMealsApply}, function() {
		alert('提交成功');
	});
}